package com.woniuxy.java102vuecli.controller;

import com.woniuxy.java102vuecli.entity.Role;
import com.woniuxy.java102vuecli.entity.RoleMneuVO;
import com.woniuxy.java102vuecli.service.RoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author author
 * @Create 2023-09-14 12:01
 */
@Slf4j
@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    RoleService roleService;

    @RequestMapping("/get/all")
    public ResponseResult<List<Role>> getAllRoles(){
        return new ResponseResult<List<Role>>(200,"success",
                roleService.getAllRoles());
    }

    @RequestMapping("/getmids/{rid}")
    public ResponseResult<List<Integer>> getMidsByRid(@PathVariable("rid") int rid){
        return new ResponseResult<List<Integer>>(200,"success",
                roleService.getMidsByRid(rid));
    }

    @RequestMapping("/allocationMenu")
    public ResponseResult<Void> allocationMenu(@RequestBody RoleMneuVO roleMenuVo){
        roleService.allocationMenu(roleMenuVo);
        return new ResponseResult<Void>(200,"success",null);
    }


}
